/*
 * FlashObject embed
 * by Geoff Stearns (geoff@deconcept.com, http://www.deconcept.com/)
 */

var iv_adv_FlashObject = function(swf, w, h) {
	this.swf = swf;
	this.width = w;
	this.height = h;

}
var iv_FOP = iv_adv_FlashObject.prototype;

iv_FOP.getHTML = function() {
    var flashHTML = "";
    if (navigator.plugins && navigator.mimeTypes.length) { // netscape plugin architecture
        flashHTML += '<embed type="application/x-shockwave-flash" wmode="transparent" src="' + this.swf + '" width="' + this.width + '" height="' + this.height + '"';
        flashHTML += '></embed>';

    } else { // PC IE
        flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.width + '" height="' + this.height +  '">';
        flashHTML += '<param name="movie" value="' + this.swf + '" />';
        flashHTML += '<param name="wmode" value="transparent" />';
        flashHTML += '</object>';
    }
    return flashHTML;	
}

iv_FOP.write = function(elementId) {

		if (elementId) {
			document.getElementById(elementId).innerHTML = this.getHTML();
		} else {
			document.write(this.getHTML());
		}

}

//**************************************************
// advertisement system common js code
// YangMeng(hvbird@gmail.com)
// 10/29/2007 10:10:41 AM
//**************************************************
function changeImga(pre)
{
	var lttalocal;
	var widths;        
	var heights;        
	var counts;
	var advtype;
	var delay;
	var circletotal;

	eval('nna='+pre+'nna');
	eval('widths='+pre+'widthsa');
	eval('heights='+pre+'heightsa');
	eval('counts='+pre+'countsa');
	eval('advtype='+pre+'advtype');
	eval('delay='+pre+'timer');
	eval('circletotal='+pre+'cirtotal');

	// 如果是轮播
	if(counts>1)
	{
		var tmpnum = Math.random()*circletotal;
		// 查找要播放的广告
		var tmpcircle;
		for(var i=1;i<=counts;i++)
		{
			eval('tmpcircle='+pre+'circle'+i);
			if(tmpcircle>tmpnum)
			{
				nna = i;
				break;
			}
		}
	}

	var cururl;
	var curmedia;
	var imgobj;
	eval('cururl='+pre+'urla'+nna);
	eval('curmedia='+pre+'imga'+nna);
	eval('imgobj='+pre+'img'+nna);

	// 弹出广告
	if(advtype == 6)
	{
		var cmd = 'jump_page(\''+pre+'\')';
		lttalocal = setTimeout(cmd,delay);	
		return;
	}
	else
	{
		// 如果本图片没有载入过，载入
		if(imgobj.src != curmedia)
		{
			imgobj.src = curmedia;
		}

		// 如果是flash文件
		if(curmedia.toLowerCase().indexOf('.swf') >0)
		{
			var fs2= new iv_adv_FlashObject(imgobj.src, widths, heights);
			fs2.write(pre+"dis");
		}
		// 文字链
		else if(curmedia.toLowerCase().indexOf('|') >0)
		{
			var stringtmp = curmedia.split('|');
			var tmptext = stringtmp[0].replace('http://advlog.yoka.com/','');
			var advcode = "<a href=\""+cururl+"\" target='_blank'>"+tmptext+"</a>";

			document.getElementById(pre+"dis").innerHTML= advcode;

			var imageObj = new Image();
			imageObj.src = 'http://advlog.yoka.com/' + stringtmp[1];
		}
		else
		{
			var advcode = "<a href=\""+cururl+"\" target='_blank'><img src='"+imgobj.src+"' border=0 /></a>";

			document.getElementById(pre+"dis").innerHTML= advcode;
		}
	}

	// 如果是全屏
	if(advtype == 7)
	{
		var cmd = 'close_adv(\''+pre+'\')';
		lttalocal = setTimeout(cmd,delay);
		return;
	}
}

// 关闭全屏
function close_adv(pre)
{
	document.getElementById(pre+"dis").style.display = "none";	
}

// 弹出窗口
function jump_page(pre)
{
	var cururl;
	eval('cururl='+pre+'urla'+nna);

	window.open(cururl);
}

// run adv
function runadv(pre)
{
	// display image
	changeImga(pre);
}
//关闭窗口
function iclose(id)
{
	var mx=document.getElementById(id).offsetHeight;
	var mi=0;

		var clearer = setInterval(function()
			{
			if(mx<0){mx=0;}
			document.getElementById(id).style.height=mx+"px";
		mx > mi ? mx-=5 : clearInterval(clearer);},10)
}

//统计代码
if(typeof(yokaImage) == 'undefined')
{
	yokaImage = new Image;
	var refurl = encodeURIComponent(document.referrer);
	yokaImage.src = "http://statistics.yoka.com/Script.aspx?ref=" + refurl + "&t=" + (Math.random()*100000);
}